package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.roo.addon.entity.RooIdentifier;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

/**
 * The Class TtlsbgecPK.
 */
@Embeddable
@Configurable
@RooIdentifier(dbManaged = true)
public final class TtlsbgecPK implements java.io.Serializable {

	/** The cod registwt. */
	@Column(name = "COD_REGISTWT", columnDefinition = "CHAR", nullable = false, length = 12)
    private String codRegistwt;

	/** The cod tipregi2. */
	@Column(name = "COD_TIPREGI2", columnDefinition = "SMALLINT", nullable = false)
    private Short codTipregi2;

	/** The cod idioma. */
	@Column(name = "COD_IDIOMA", columnDefinition = "SMALLINT", nullable = false)
    private Short codIdioma;

	/** The cod bancoint. */
	@Column(name = "COD_BANCOINT", columnDefinition = "SMALLINT", nullable = false)
    private Short codBancoint;

	/**
	 * Instantiates a new ttlsbgec pk.
	 *
	 * @param codRegistwt the cod registwt
	 * @param codTipregi2 the cod tipregi2
	 * @param codIdioma the cod idioma
	 * @param codBancoint the cod bancoint
	 */
	public TtlsbgecPK(String codRegistwt, Short codTipregi2, Short codIdioma, Short codBancoint) {
        super();
        this.codRegistwt = codRegistwt;
        this.codTipregi2 = codTipregi2;
        this.codIdioma = codIdioma;
        this.codBancoint = codBancoint;
    }

	/**
	 * Instantiates a new ttlsbgec pk.
	 */
	@SuppressWarnings("unused")
	private TtlsbgecPK() {
        super();
    }

	/**
	 * Gets the cod registwt.
	 *
	 * @return the cod registwt
	 */
	public String getCodRegistwt() {
        return this.codRegistwt;
    }

	/**
	 * Gets the cod tipregi2.
	 *
	 * @return the cod tipregi2
	 */
	public Short getCodTipregi2() {
        return this.codTipregi2;
    }

	/**
	 * Gets the cod idioma.
	 *
	 * @return the cod idioma
	 */
	public Short getCodIdioma() {
        return this.codIdioma;
    }

	/**
	 * Gets the cod bancoint.
	 *
	 * @return the cod bancoint
	 */
	public Short getCodBancoint() {
        return this.codBancoint;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (!(obj instanceof TtlsbgecPK)) return false;
        TtlsbgecPK other = (TtlsbgecPK) obj;
        if (codRegistwt == null) {
            if (other.codRegistwt != null) return false;
        } else if (!codRegistwt.equals(other.codRegistwt)) return false;
        if (codTipregi2 == null) {
            if (other.codTipregi2 != null) return false;
        } else if (!codTipregi2.equals(other.codTipregi2)) return false;
        if (codIdioma == null) {
            if (other.codIdioma != null) return false;
        } else if (!codIdioma.equals(other.codIdioma)) return false;
        if (codBancoint == null) {
            if (other.codBancoint != null) return false;
        } else if (!codBancoint.equals(other.codBancoint)) return false;
        return true;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
        final int prime = 31;
        int result = 17;
        result = prime * result + (codRegistwt == null ? 0 : codRegistwt.hashCode());
        result = prime * result + (codTipregi2 == null ? 0 : codTipregi2.hashCode());
        result = prime * result + (codIdioma == null ? 0 : codIdioma.hashCode());
        result = prime * result + (codBancoint == null ? 0 : codBancoint.hashCode());
        return result;
    }

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/**
	 * To json.
	 *
	 * @return the string
	 */
	public String toJson() {
        return new JSONSerializer().exclude("*.class").serialize(this);
    }

	/**
	 * From json to ttlsbgec pk.
	 *
	 * @param json the json
	 * @return the ttlsbgec pk
	 */
	public static TtlsbgecPK fromJsonToTtlsbgecPK(String json) {
        return new JSONDeserializer<TtlsbgecPK>().use(null, TtlsbgecPK.class).deserialize(json);
    }

	/**
	 * To json array.
	 *
	 * @param collection the collection
	 * @return the string
	 */
	public static String toJsonArray(Collection<TtlsbgecPK> collection) {
        return new JSONSerializer().exclude("*.class").serialize(collection);
    }

	/**
	 * From json array to ttlsbgec p ks.
	 *
	 * @param json the json
	 * @return the collection
	 */
	public static Collection<TtlsbgecPK> fromJsonArrayToTtlsbgecPKs(String json) {
        return new JSONDeserializer<List<TtlsbgecPK>>().use(null, ArrayList.class).use("values", TtlsbgecPK.class).deserialize(json);
    }
}
